﻿/* 10. In the combinatorial mathematics, the Catalan numbers are calculated by the following formula: 
 * C(n) = 1/(n+1) * (2n under n) = (2n)! / n!(n+1)! for n >= 0 . 
 * Write a program to calculate the N-th Catalan number by given N. */

// Add Reference to 'System.Numerics'.

using System;
using System.Numerics;

public class CatalanNumber
{
    public static void Main()
    {
        int n;
        BigInteger c = 1;

        do
        {
            Console.Clear();
            Console.Write("n = ");
            if ((int.TryParse(Console.ReadLine(), out n)) && (0 <= n))
                break;
        } while (true);

        Console.Write("C{0} = ", n);
        if (n == 0)
            Console.WriteLine("0");
        else
        {
            for (int i = 2 * n; i > n; i--)
                c *= i;

            for (int i = n + 1; i > 1; i--)
                c /= i;

            Console.WriteLine(c);
        }
    }
}